package com.itboye.eweilisten.me.timu;

import android.util.Log;
import android.view.ViewGroup;

import com.itboye.eweilisten.model.TiTwo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 做题（内容）
 */
public class ReadZuoTi {
    /**
     * 对题中内容的操作
     * @param str
     * @return
     */
    public static String read(ArrayList<String[]> str) {
        StringBuffer sb = new StringBuffer();
        for (int j = 0; j < str.size(); j++) {
            String[] s1 = str.get(j);
            List<String> userList = Arrays.asList(s1);
            Log.d("userListuserList", userList.size() + "");
            if (userList.get(0).toString().equals("str")) {
                sb.append(userList.get(1));
            } else if (userList.get(0).toString().equals("img")) {
                sb.append(userList.get(1));
            }
            if (userList.get(0).toString().equals("con")) {
                if (userList.get(1).equals("")) {
                    sb.append("  ____  ");
                } else if (userList.get(1).equals("\n")) {
                    sb.append(userList.get(1) + "        ");
                }
            }
        }
        return sb.substring(0, sb.length());
    }

    /**
     * 对答案的操作（单选，图片选择）
     * @param answer
     * @return
     */
    public static List<TiTwo> daan(ArrayList<String[]> answer){
        List<TiTwo> tilist=new ArrayList<>();
        for (int j = 0; j < answer.size(); j++) {
            TiTwo two = new TiTwo();
            String[] s1 = answer.get(j);
            List<String> userList = Arrays.asList(s1);
            two.setXuan(userList.get(0));
            two.setImg(userList.get(2));
            tilist.add(two);
        }
        return tilist;
    }

    public static String Image(ArrayList<String> str) {
        StringBuffer sb = new StringBuffer();
        for (int j = 0; j < str.size(); j++) {
            String s1 = str.get(j);
            List<String> userList = Arrays.asList(s1);
            Log.d("userListuserList", userList.size() + "");

            if (userList.get(j).toString().equals("img")) {
                sb.append(userList.get(j));
            }
        }
        return sb.substring(0, sb.length());
    }

    /**
     * 添加布局
     * @return
     */
    public static ViewGroup.MarginLayoutParams addViewLayout() {
        ViewGroup.MarginLayoutParams layoutParams01 = new ViewGroup.MarginLayoutParams(
                ViewGroup.MarginLayoutParams.MATCH_PARENT,
                ViewGroup.MarginLayoutParams.WRAP_CONTENT);
        layoutParams01.setMargins(5, 5, 5, 5);
        return layoutParams01;
    }

}
